<template>
	<view class="content">
		<image src="../../static/login.png" style="width: 289rpx;height: 326rpx;margin: 20rpx auto; margin-bottom: 80rpx;"></image>
		<input type="text" v-model="account" placeholder="账户号"/>
		<input type="password"  v-model="password" placeholder="密码" />
		<button class="u-reset-button btn1" @click="login">登录</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				account:'',
				password:''
			}
		},
		methods: {
			login(){
				if(this.account == ''){
					uni.showToast({
						icon:'none',
						title:'请输入账号'
					})
					return false
				}
				if(this.password == ''){
					uni.showToast({
						icon:'none',
						title:'请输入密码'
					})
					return false
				}
				uni.$u.http.post('/user/login',{
					account:this.account,
					password:this.password
				}).then(res =>{
					console.log(res)
					uni.setStorageSync('token',res.data.userinfo.token)
					uni.showToast({
						icon:'none',
						title:res.msg
					})
					setTimeout(()=>{
						uni.switchTab({
							url:'/pages/my/my'
						})
					},500)
				}).catch(err =>{
					uni.showToast({
						icon:'none',
						title:err.data.msg
					})
				})
			}
		}
	}
</script>

<style lang="less">
	.content{
		height: 100vh;
		background: #FFFFFF;
		margin: 10rpx 20rpx;
		border-radius: 20rpx;
		display: flex;
		flex-direction: column;
		/* justify-content: center; */
		/* align-items: center; */
		/* justify-content: center; */
		padding: 20rpx ;
		input{
			width: 100%;
			height: 80rpx;
			margin-bottom: 20rpx;
			border-bottom: 1px solid #e7e7e7;
		}
	}
.btn1{
	width: 650rpx;
	height: 80rpx;
	background: #FBAA27;
	border-radius: 40rpx;
	color: #FFFFFF;
	font-size: 36rpx;
	font-weight: bold;
	line-height: 80rpx;
	margin-top: 100rpx;
}
</style>
